<!DOCTYPE html>
<meta charset="utf-8">
<title>SkipAd - media session action exposed by origin trial</title>
<script src="../../../../resources/testharness.js"></script>
<script src="../../../../resources/testharnessreport.js"></script>
<script src="../../../../resources/origin-trials-helper.js"></script>

<script>
// Can only run this test if SkipAd is not enabled via a Chrome flag.
// That is only the case when running this in a virtual test suite (by default,
// runtime enabled features are on for layout tests).
// To run in virtual test suite:
// tools/run_web_tests.py virtual/origin-trials-runtimeflags-disabled/http/tests/origin_trials/webexposed
if (!self.internals.runtimeFlags.skipAdEnabled) {
  test(t => {
    assert_throws_js(TypeError, function() {
      navigator.mediaSession.setActionHandler('skipad', function() {});
    });
    assert_throws_js(TypeError, function() {
      navigator.mediaSession.setActionHandler('skipad', null);
    });
  }, 'skipad media session action in Origin-Trial disabled document.');
}

// generated with command
// tools/origin_trials/generate_token.py http://127.0.0.1:8000 SkipAd --expire-timestamp=2000000000
const token = 'AnO+YFdm66rVdQ2ZEckocTP2NIsSxSK8BqyMlgIO/sCbXb484ga4DdbgLOn5z52n6WE9HxpKiB9XI97zDfTGvQoAAABOeyJvcmlnaW4iOiAiaHR0cDovLzEyNy4wLjAuMTo4MDAwIiwgImZlYXR1cmUiOiAiU2tpcEFkIiwgImV4cGlyeSI6IDIwMDAwMDAwMDB9';
OriginTrialsHelper.add_token(token);
test(t => {
  navigator.mediaSession.setActionHandler('skipad', function() {});
  navigator.mediaSession.setActionHandler('skipad', null);
}, 'skipad media session action in Origin-Trial enabled document.');
</script>
